import React, { useEffect, useState } from 'react'
import { Link, useNavigate } from 'react-router-dom'
export default function NotFound() {
  const [time, setTime] = useState(3)
  const navigate = useNavigate()
  useEffect(() => {
    setTimeout(() => {
      setTime(time - 1)
    }, 1000)
    if (time === 0) {
      navigate('/')
    }
  }, [time, navigate])
  return (
    <div>
      <h1>对不起，你访问的内容不存在...</h1>
      <p>
        {time} 秒后，返回<Link to="/">首页</Link>
      </p>
    </div>
  )
}
